// Get drive list and volume names.
// Returns the current drives and their labels
// By DreamVB 13:20 17/09/2016

#include <iostream>
#include <Windows.h>
#include <vector>

using namespace std;
using std::cout;
using std::endl;

void GetMyDrives(vector<string>&drives){
	//Return a list of current drives on the system.
	DWORD dMask = GetLogicalDrives();
	int i = 0;
	string s0 = "";

	while (i < 26){
		if (dMask & (1 << i)){
			s0 = (char)('A' + i);
			//Add drive letter to vector.
			drives.push_back(s0);
		}
		//INC counter
		i++;
	}
}

string GetDriveName(string Drive){
	char volname[196];
	//Return drive volume name
	if (GetVolumeInformationA(Drive.c_str(), volname, 196, 0, 0, NULL, NULL, 0) != 0){
		return volname;
	}
	return "NO_LABEL";
}

int main(int argc, char *argv[]){
	vector<string>d;
	//Get drive letters
	GetMyDrives(d);

	for each (string var in d)
	{
		//Display drive letters and drive volume names.
		cout << "Drive " << var.c_str() << "   " <<
			GetDriveName(var + ":\\").c_str() << endl;
	}

	system("pause");
	return 0;
}